<?php
/* @var $this MakananController */
/* @var $model Post */
/* @var $form TbActiveForm */
?>

<div class="form">

    <?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm', array(
	'id'=>'post-form',
	// Please note: When you enable ajax validation, make sure the corresponding
	// controller action is handling ajax validation correctly.
	// There is a call to performAjaxValidation() commented in generated controller code.
	// See class documentation of CActiveForm for details on this.
	'enableAjaxValidation'=>false,
	'htmlOptions'=>array(
		'enctype'=>'multipart/form-data',
	),
)); ?>

    <p class="help-block">Fields with <span class="required">*</span> are required.</p>

    <?php echo $form->errorSummary($model); ?>

            <?php echo $form->textFieldControlGroup($model,'judul',array('span'=>5,'maxlength'=>45)); ?>

            <?php echo $form->fileFieldControlGroup($model,'image_header',array('span'=>5,'maxlength'=>255)); ?>
	
			<?php if(!$model->isNewRecord): ?>
			<?php echo TbHtml::label("Image Sekarang: ",'curimg')?>
			<?php echo TbHtml::image($model->getPictureUrl('image_header', 'makananSrc'),'curimg',array('id'=>'curimg')); ?>
			<?php endif; ?>
	
            <?php echo $form->fileFieldControlGroup($model,'image_excerpt',array('span'=>5,'maxlength'=>255)); ?>
			
			<?php if(!$model->isNewRecord): ?>
			<?php echo TbHtml::label("Image Excerpt Sekarang: ",'curimgex')?>
			<?php echo TbHtml::image($model->getPictureUrl('image_excerpt', 'makananSrc'),'curimgex',array('id'=>'curimgex')); ?>
			<?php endif; ?>

            <?php $this->widget('vendorext.eckeditor.ECKEditor', array(
				'model'=>$model,
                'attribute'=>'konten',
                'config' => array(
					'toolbar'=>array(
						array( 'Source', '-', 'Bold', 'Italic', 'Underline', 'Strike' ),
                        array( 'Image', 'Link', 'Unlink', 'Anchor' ) ,
                    ),
                  ),
			)); ?>
	
			<?php
			$elementBahan = array(
				'elements' => array(
					//'barang_masuk_id'=>array('visible'=>false,'value'=>$detail_transaksi->id),

					'bahan' => array(
						'type' => 'text',
						'placeholder'=>'Bahan',
						'maxlength' => 40,
					),
					'banyak' => array(
						'type' => 'text',
						'placeholder'=>'Banyak',
						'maxlength' => 4,
					),
					'satuan_id' => array(
						'type' => 'dropdownlist',
						'items'=>array(""=>"Pilih Satuan")+CHtml::listData($listSatuan,'id','nama'),
						'data-placeholder'=>$postIngredientAttr['satuan_id'],
						'placeholder'=>'Order',
						'maxlength' => 4,
					),
			));
			
			$multimodelform = $this->widget('ext.multimodelform.MultiModelForm', array(
				'id' => 'bahan', //the unique widget id
				'renderForm'=>'MultiModelRenderForm',
				'formConfig' => $elementBahan, //the form configuration array
				'model' => new PostIngredient(), //instance of the form model
				'validatedItems' => $validatedPostIngredient,
				'data' => PostIngredient::model()->findAll(array('condition'=>"post_id='$model->id'")),
				'hideCopyTemplate' => false,
				'clearInputs' => true,			
				'jsRelCopy'=>'jquery.relcopy.yii.6.0Chosen.js',
				'addItemText'=>'(+) Bahan',
				'bootstrapLayout'=>true,
				'rowWrapper'=>array(
					'htmlOptions'=>array(
						//'tag'=>'div',
						'class'=>'add-item-data',
					),
				)
			),true);

			echo TbHtml::customActiveControlGroup($multimodelform, $model, '');
			?>
			
			 <?php $this->widget('vendorext.eckeditor.ECKEditor', array(
				'model'=>$model,
                'attribute'=>'konten_excerpt',
                'config' => array(
					'toolbar'=>array(
						array( 'Source', '-', 'Bold', 'Italic', 'Underline', 'Strike' ),
                        array( 'Image', 'Link', 'Unlink', 'Anchor' ) ,
                    ),
                  ),
			)); ?>

            <?php echo $form->checkBoxControlGroup($model,'halal',array('span'=>5)); ?>

            <?php echo $form->checkBoxControlGroup($model,'daging',array('span'=>5)); ?>

            <?php echo $form->checkBoxControlGroup($model,'sayuran',array('span'=>5)); ?>

            <?php echo $form->checkBoxControlGroup($model,'buah',array('span'=>5)); ?>

            <?php echo $form->checkBoxControlGroup($model,'susu',array('span'=>5)); ?>

            <?php echo $form->checkBoxControlGroup($model,'telur',array('span'=>5)); ?>

            <?php echo $form->checkBoxControlGroup($model,'tumbuhan_polong',array('span'=>5)); ?>

            <?php echo $form->checkBoxControlGroup($model,'berbiji',array('span'=>5)); ?>

            <?php echo $form->checkBoxControlGroup($model,'padi_padian',array('span'=>5)); ?>

            <?php echo $form->textFieldControlGroup($model,'jumlah_kalori',array('span'=>5)); ?>
			
			<?php
				$category = $this->widget('ext.selectize.YiiSelectize', array(
					'model' => $model,
					'attribute' => 'categories',
					'data'=>CHtml::listData($listKategori,'nama','nama'),
					'useWithBootstrap' => true,
					//'cssTheme' => 'bootstrap2', // uncomment to use v2 theme instead of v3
					'fullWidth' => false,
					'multiple'=>true,
					'selectedValues'=>$selectedValues,
				),true);
				echo TbHtml::customActiveControlGroup($category, $model, 'Kategori Makanan');
			?>
	
            <?php echo $form->checkBoxControlGroup($model,'active',array('span'=>5)); ?>
			
        <div class="form-actions">
        <?php echo TbHtml::submitButton($model->isNewRecord ? 'Create' : 'Save',array(
		    'color'=>TbHtml::BUTTON_COLOR_PRIMARY,
		    'size'=>TbHtml::BUTTON_SIZE_LARGE,
		)); ?>
    </div>

    <?php $this->endWidget(); ?>

</div><!-- form -->